<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/lodash.js/4.17.21/lodash.min.js" type="application/javascript"></script>
  </head>
  <body></body>
  <script>
    //原始数据
    let rows = [
      {
        id: "604f764971f93f3ac8f365c2",
        mobile: "13800000002",
        username: "我是吕冠哥",
        password: "e10adc3949ba59abbe56e057f20f883e",
        enableState: "在职",
        timeOfEntry: "2018-11-02",
        formOfEmployment: "2",
        workNumber: "9002",
        correctionTime: "2018-11-30",
        departmentName: "总裁办",
        staffPhoto:
          "https://pic3.zhimg.com/80/v2-30d38a78345919efb417ced32e7d077a_720w.webp",
      }
    ];
    //目标数据
    //(1)考虑结果,做一个人类思考问题
    // 形成二维数组
    // 对照excel每一列,赋值值,按照顺序,粘贴到里面数组当中
    /*
    let data = [[ "我是吕冠哥","13800000002","2018-11-02","2","2018-11-30","9002","总裁办"]]
    */
    //(2)考虑对哪些数据做哪些操作,按照机器思考问题
    // 对象-过滤
    // dom->jquery->vue/react/小程序
    // es6/es5->lodash
    /*
    let item = {}
    for(var key in rows[0]){
      if(['username', 'mobile','timeOfEntry','formOfEmployment','correctionTime','workNumber','departmentName'].includes(key)){
        item[key] = rows[0][key]
      }
    }
    */
    // let item = _.pick(rows[0], ['username', 'mobile','timeOfEntry','formOfEmployment','correctionTime','workNumber','departmentName'])
    // console.log(item)

    // 对象-获取值
    // console.log(Object.values(item))
    // 数组-从久的数组,生成一个新的数组
    //不用map
    /*
    let l = [1,2,3]
    let n = []
    l.forEach(t => {
      n.push(t*2)
    })
    */
    //使用map
    //省略数组赋初值
    /*
    let l = [1,2,3]
    let n = l.map(t=>{
      //省略push
      return t*2
    })
    */
    /*
    let l = [1,2,3]
    let n = l.map(t=> t*2)
    console.log(n)
    */
    let data = rows.map(t=>{
      return Object.values(_.pick(t, ['username', 'mobile','timeOfEntry','formOfEmployment','correctionTime','workNumber','departmentName']))
    })
    console.log(data)

  </script>
</html>
